package com.lirh.mysql.controller;

import com.lirh.mysql.entity.User1Entity;
import com.lirh.mysql.entity.User2Entity;
import com.lirh.mysql.service.Uesr1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
//    @Autowired
//    private RedisTemplate<Object,User1Entity> redisTemplate;
@Autowired
private RedisCacheManager redisCacheManager;
@Autowired
private Uesr1Service uesr1Service;

    @GetMapping("/test")
    public String test12(@RequestParam("id") String id){
        uesr1Service.testAsync();
        return "ok";
    }
    @GetMapping("/test2")
    public User2Entity test2(){
        System.out.println("test2 method 调用");
        User2Entity user1Entity = new User2Entity();
        user1Entity.setAge("18");
        user1Entity.setName("lirh");
        Cache mana = redisCacheManager.getCache("mana");
        mana.put("id",user1Entity);
        return user1Entity;
    }
}
